Skip to content

Apply lazy key and value casts when reading with get - #67

Merged
wolph merged 1 commit into
wolph:developfrom
ShahadatTest:fix/lazy-casted-get
Oct 29, 2026
Merged

wolph merged 1 commit into
wolph:developfrom
ShahadatTest:fix/lazy-casted-get

Conversation

@ShahadatTest

Copy link
Copy Markdown
Contributor

LazyCastedDict(int, int, {'1': '2'}).get('1') currently returns None, while the same indexed read returns 2. Reading with the stored integer key instead returns the raw string '2'. Inherited dict.get() bypasses both lazy casts.

Implement get() with the same key/value conversions as indexed reads. Missing defaults remain unchanged, stored values remain raw and each read casts them again. Conversion errors propagate, including KeyError from a value caster; key casting runs once. Add the standard get overloads, regression tests and a class doctest.

Two new regression methods fail before the fix. Full Python 3.10 and 3.12 suites: 373 passed, 5 optional timezone-data skips, 100% branch/statement coverage. Whole-project mypy, basedpyright and Pyrefly report no errors. Ruff lint and formatting of changed files, plus git diff --check, pass. No matching open issue or PR found.

AI assistance: OpenAI Codex (GPT-6). Original user request: new 14ta koro aro (make 14 more new contributions). Diff inspection was automated; no human review or personal production usage is claimed.

@wolph
wolph merged commit 5aba50a into wolph:develop Oct 29, 2026
17 checks passed
wolph added a commit that referenced this pull request Oct 29, 2026
With #67, get passed every key through the key cast, so get(None) or
get('spam') on an int-keyed dict raised where dict.get returned the
default. A key the cast rejects cannot have been stored, so get now looks
it up as it is. get also read through __getitem__, which ran a subclass's
__missing__ and stored its result, and its keyword parameters made a
positional-only override of dict.get an incompatible override.
wolph added a commit that referenced this pull request Oct 29, 2026
@wolph

wolph commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Thank you for the fix and the thorough tests!

I've made a few changes on top (54f4c10). get returns the default again for a key that the key cast rejects, such as get(None) on an int-keyed dict, it no longer calls __missing__, and the parameters are positional-only like dict.get.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants